<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>
    <h1>proxy代理</h1>
    <input type="text" id="input">
    <h2>你输入的类容:<i id="txt"></i></h2>

</body>

</html>
<script>
    let oInput = document.getElementById("input");
    let oTxt = document.getElementById("txt");
    let obj = {};
    let newProxy = new Proxy(obj, {
        get(target, key, recevier) {
            return Reflect.get(target, key, recevier);
        },
        set(target, key, value, recevier) {
            // console.log(target)
            // console.log(key)
            // console.log(value)
            // console.log(recevier)
            if (key == "text") {
                oTxt.innerHTML = value;
            }
            return Reflect.set(target, key, value, recevier);
        }
    });
    oInput.addEventListener("keyup", function (e) {
        newProxy.text = e.target.value;
    })
</script>